package org.feng.navigation.web.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.MDC;
import org.springframework.context.annotation.Configuration;

/**
 * Feign 拦截器：给请求header中设置 “businessId”
 *
 * @version V1.0
 * @author: junzi
 * @date: 2023年02月01日 10时50分
 */
@Configuration
public class FeignInterceptor implements RequestInterceptor {

    private static final String BUSINESS_ID = "businessId";

    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(BUSINESS_ID, MDC.get(BUSINESS_ID));
    }
}
